//网络服务（具体业务）
//用法：登录，登出，获取玩家信息，
//用法：建立游戏房间，进入游戏房间，取消游戏房间(游戏未开始)，关闭游戏房间(游戏结束)
//用法：发送游戏数据到服务器，接收服务器游戏数据

var netService = {
	gamehost : "http://127.0.0.1:8080/campaignlab/",
	
	Login : function(usertext, password, handler, recalltime){
		PostHttpRequest(this.gamehost + "/g/login",
				"usertext=" + usertext + "&password=" + password,
				handler, recalltime);
	},

	Logout : function(userid, handler, recalltime){
		PostHttpRequest(this.gamehost + "/g/logout",
				"id=" + userid,
				handler, recalltime);
	},
	
	GetUser : function(userid, handler, recalltime){
		PostHttpRequest(this.gamehost + "/g/getuser",
				"id=" + userid,
				handler, recalltime);
	},
	
	BuildRoom : function(userid, roomString, handler, recalltime){
		PostHttpRequest(this.gamehost + "/g/buildroom",
				"id=" + userid + "&room=" + roomString,
				handler, recalltime);
	},
	
	EnterRoom : function(userid, roomid, handler, recalltime){
		PostHttpRequest(this.gamehost + "/g/enterroom",
				"id=" + userid + "&roomid=" + roomid,
				handler, recalltime);
	},
	
	CancelRoom : function(userid, roomid, handler, recalltime){
		PostHttpRequest(this.gamehost + "/g/cancelroom",
				"id=" + userid + "&roomid=" + roomid,
				handler, recalltime);
	},

	CloseRoom : function(userid, roomid, score, handler, recalltime){
		PostHttpRequest(this.gamehost + "/g/closeroom",
				"id=" + userid + "&roomid=" + roomid + "&score=" + score,
				handler, recalltime);
	},
	
	GetRoom : function(userid, roomid, handler, recalltime){
		PostHttpRequest(this.gamehost + "/g/getroom",
				"id=" + userid + "&roomid=" + roomid,
				handler, recalltime);
	},

	BuildData : function(userid, dataString, handler, recalltime){
		PostHttpRequest(this.gamehost + "/g/builddata",
				"id=" + userid + "&data=" + dataString,
				handler, recalltime);
	},
	
	GetData : function(userid, roomid, gameuserid, type, fromtime, handler, recalltime){
		gameuserid = gameuserid || "";
		PostHttpRequest(this.gamehost + "/g/getdata",
				"id=" + userid + "&roomid=" + roomid + "&userid="
				+ gameuserid + "&type=" + type + "&fromtime=" + Math.floor(fromtime / 1000),
				handler, recalltime);
	}
};